<?php
class FolderVisitor{
	function __contruct(){
		// Lo hago instanciable para poder pasear
		// la instancia entre los nodos a visitar.
	}
	
	/**
	 * Agrega una carpeta al árbol.
	 * @param LogicTreeNode $tree
	 */
	function visit($tree){
		// TODO: probar.
		$name = $tree->getName();
		$level = $tree->getLevel();
		$id = $tree->getId();
		if($tree->getLevel() == 0){			
			?>
foldersTree = gFld("<img src='../img/folder.gif'></img> <i><?php echo $name?></i> <a href='javascript:linkFuncionX(<?php echo $id; ?>)'>FuncionX</a>", "javascript:redirect(\"abmModulo.php\", \"abmElement\", \"idParent=<?php echo $id; ?>\", \"POST\")")
<?php
		} else {
			// Indento
			$i = 0;
			while($i != $level){
				echo "  ";
				$i++;
			}
			
			$levelMinusOne = $level - 1;
			if($level != 1){
			?>
aux<?php echo $level; ?> = insFld(aux<?php echo $levelMinusOne; ?>, gFld("<img src='../img/folder.gif'></img> <?php echo $name; ?> <a href='javascript:linkFuncionX(<?php echo $id; ?>)'>FuncionX</a>", "javascript:redirect(\"abmModulo.php\",\"abmElement\",\"idParent=<?php echo $id; ?>\",\"POST\")"))
<?php
			} else {
			?>
aux1 = insFld(foldersTree, gFld("<img src='../img/folder.gif'></img> <?php echo $name; ?> <a href='javascript:linkFuncionX(<?php echo $id; ?>)'>FuncionX</a>", "javascript:redirect(\"abmModulo.php\",\"abmElement\",\"idParent=<?php echo $id; ?>\",\"POST\")"))
<?php
			}
			echo "\n";
		}
	}
}